import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
const path = require('path');
const babel = require('rollup-plugin-babel');
const pkg = require('./package.json');

const extensions = ['.js', '.ts'];

const resolve = function(...args) {
  return path.resolve(__dirname, ...args);
};

module.exports = {
  input: resolve('./index.ts'),
  output: {
    file: resolve('./', pkg.main), // 为了项目的统一性，这里读取 package.json 中的配置项
    format: 'iife',
  },
  plugins: [
    typescript({
      tsconfig: './tsconfig.json'
    }),
    babel({
      exclude: 'node_modules/**',
      extensions,
    }),
    terser()
  ],
};